﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="JSEvent.cs" company="SMART business">
//   Copyright (c) 2014 All Rights Reserved
// </copyright>
// <summary>
//   The java script event class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ComparisonTool
{
    using System;

    /// <summary>
    /// The java script event class.
    /// </summary>
    public class JsEvent : IEquatable<JsEvent>
    {
        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the function name.
        /// </summary>
        public string FunctionName { get; set; }

        /// <summary>
        /// Gets or sets the library name.
        /// </summary>
        public string LibraryName { get; set; }

        /// <summary>
        /// Gets or sets the attribute.
        /// </summary>
        public string Attribute { get; set; }

        /// <summary>
        /// Gets or sets the attribute display name.
        /// </summary>
        public string AttributeDisplayName { get; set; }

        /// <summary>
        /// The equals.
        /// </summary>
        /// <param name="other">
        /// The other.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Equals(JsEvent other)
        {
            // Check whether the compared object is null.
            if (ReferenceEquals(other, null))
            {
                return false;
            }

            // Check whether the compared object references the same data.
            if (ReferenceEquals(this, other))
            {
                return true;
            }

            // Check whether the products' properties are equal.
            return this.Name.Equals(other.Name) && this.FunctionName.Equals(other.FunctionName) &&
                    this.LibraryName.Equals(other.LibraryName);
        }

        /// <summary>
        /// The get hash code.
        /// </summary>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public override int GetHashCode()
        {
            // Get hash code for the Name field if it is not null.
            var hashName = this.Name == null ? 0 : this.Name.GetHashCode();

            // Get hash code for the Function Nmae field.
            var hashFunctionName = this.FunctionName.GetHashCode();

            // Get hash code for the Library Name field.
            var hashLibraryName = this.LibraryName.GetHashCode();

            // Calculate the hash code for the product.
            return hashName ^ hashFunctionName ^ hashLibraryName;
        }
    }
}